import { useHappyKitRouter } from "@va/framework"
// @ts-ignore
import { createRouter, createWebHashHistory,  NavigationGuardNext, RouteLocationNormalized, RouteLocationRaw } from "vue-router";
import { onBeforeEach } from "./guard"

const routes: RouteLocationRaw[] = [
    {
        name     : 'layout',
        path     : '/',
        redirect     : '/home',
        component: () => import('/src/layout/base-layout.vue'),
        children: [
            {
                name     : 'home',
                path     : '/home',
                component: () => import('/src/views/home/index.vue')
            }
        ],

    },
    {
        name     : 'login',
        path     : '/login',
        component: () => import('/src/views/login/index.vue')
    },

];
const router = createRouter({
    // 4. Provide the history implementation to use. We are using the hash history for simplicity here.
    history: createWebHashHistory(),
    routes // short for `routes: routes`
})

router.beforeEach(onBeforeEach)
const { happyKitRouter, RouteAlive, getCached, getIncludes, removeComponentCache } = useHappyKitRouter(router)
export {
    RouteAlive, getCached, getIncludes, removeComponentCache
}

export default happyKitRouter